#include "driver.h"
#include "game.h"
#include "glgameoptions.h"
#include "glgraphoptions.h"
#include "glinstructions.h"
#include "glstory.h"
#include "gltitle.h"

/*------------------------------------------------------------------*/

game myGame;

int main(int argc, char *argv[])
{
	freopen("stellar_log.txt","w",stdout);

	// Main SDL Settings
	SDL_Init(SDL_INIT_EVERYTHING|SDL_INIT_AUDIO);
	SDL_Surface *icon = IMG_Load("images/icon.bmp");
	SDL_WM_SetIcon(icon,NULL);

	SDL_SetVideoMode(X_DIM,Y_DIM,32,SDL_OPENGL|SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_HWACCEL);//|SDL_FULLSCREEN);
	SDL_WM_SetCaption("Stellar", NULL);

	GAMETYPE gtype;
	graphOptions myGraphOpts;
	GAMESTATE state = TITLE;

	while(state != QUIT)
	{
		switch(state)
		{
			case TITLE:
				state = titleScreen();
				break;
			case GAME_OPT:
				state = displayGameOptionPage(gtype);
				break;
			case GRAPH_OPT:
				state = displayGraphOptionPage(myGraphOpts);
				break;
			case STORY:
				state = storyScreen();
				break;
			case INST:
				state = displayInstructionsPage();
				break;
			case GAME:
				state = myGame.start(gtype,myGraphOpts);
				break;
			case RESULTS:
				state = myGame.results();
				break;
			case QUIT:  break;
		}
	}

	SDL_Quit();
	return (0);
}

/*------------------------------------------------------------------*/